package com.cyx;

import java.util.Scanner;

/**
 * @author 陈裕星
 * @version 1.0
 */
public class 最长公共前缀 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String str[] = new String[n];
        for (int i = 0; i < n; i++) {
            str[i] = sc.next();
        }
        String prefix = str[0];
        for (int i = 1; i < n; i++) {
            while(str[i].indexOf(prefix) != 0){
                prefix = prefix.substring(0,prefix.length()-1);
            }
            if (prefix.isEmpty()){
                System.out.println("不存在");
            }
        }
        System.out.println(prefix);
    }
}
